package com.sgt.frp.utils;

import com.sgt.frp.VO.FrpConnect;
import org.ini4j.Ini;

import java.util.Random;

public class IniUtils {

    public static void setCommonMsg(Ini ini,String serverPort, int port){
        ini.add("common","server_addr",serverPort);
        ini.add("common","server_port",port);
    }

    public static void setHttpOrHttpsMsg(Ini ini, FrpConnect frpConnect){
        String name=frpConnect.getType()+"_"+ new Random().nextInt(100);
        ini.add(name,"type",frpConnect.getType());
        ini.add(name,"local_ip",frpConnect.getLocalIp());
        ini.add(name,"local_port",frpConnect.getLocalPort());
        ini.add(name,"custom_domains",frpConnect.getCustomDomains()[0]);
    }

    public static void setTcpOrUdp(Ini ini, FrpConnect frpConnect){
        String name=frpConnect.getType()+"_"+ new Random().nextInt(100);
        ini.add(name,"type",frpConnect.getType());
        ini.add(name,"local_ip",frpConnect.getLocalIp());
        ini.add(name,"local_port",frpConnect.getLocalPort());
        ini.add(name,"remote_port",frpConnect.getRemotePort());
    }}
